package com.pureut.storage.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.pureut.storage.dto.IncomingMaterialPrintingDto;
import com.pureut.storage.service.IncomingMaterialPrintingService;
import com.pureut.storage.vo.IncomingMaterialPrintingVo;
import com.pureut.storage.vo.OneKeyWarehousingVo;
import com.pureut.storage.vo.UpdatePrintStatusVo;
import com.sale.common.core.domain.R;
import com.sale.common.core.web.controller.BaseController;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/***
 * 采购打印控制层
 * Author:C
 * Date:2023/01/16 14:11
 * @DESC
 */
@RestController
@RequestMapping("/incoming-material-printing")
public class IncomingMaterialPrintingController extends BaseController {

    @Resource
    IncomingMaterialPrintingService incomingMaterialPrintingService;

    /**
     * 采购打印列表
     */
    //@SaCheckPermission("warehouse:incomingPrint:print:list")
    @GetMapping("/list")
    public TableDataInfo<IncomingMaterialPrintingDto> getList(IncomingMaterialPrintingVo incomingMaterialPrintingVo, PageQuery pageQuery) {
        //查询采购打印列表
        return incomingMaterialPrintingService.getIncomingMaterial(incomingMaterialPrintingVo, pageQuery);
    }

    /**
     * 采购打印详情
     */
    //@SaCheckPermission("warehouse:incomingPrint:cgPrint:query")
    @GetMapping("/getView/{id}")
    public R<IncomingMaterialPrintingDto> getPrintView(@PathVariable("id") long id) throws Exception {
        return R.ok(incomingMaterialPrintingService.getPrintView(id));
    }

    /**
     * 采购打印一键入库
     */
    //@SaCheckPermission("warehouse:incomingPrint:cgPrint:warehousing")
    @PostMapping("/oneKeyWarehousing")
    public R<Void> oneKeyWarehousing(@RequestBody OneKeyWarehousingVo oneKeyWarehousingVo) {
        return toAjax(incomingMaterialPrintingService.oneKeyWarehousing(oneKeyWarehousingVo));
    }

    /**
     * 委外打印一键入库
     */
    //@SaCheckPermission("warehouse:incomingPrint:cgPrint:warehousing")
    @PostMapping("/oneKeyWarehousingSub")
    public R<Void> oneKeyWarehousingSub(@RequestBody OneKeyWarehousingVo oneKeyWarehousingVo) {
        return toAjax(incomingMaterialPrintingService.oneKeyWarehousingSub(oneKeyWarehousingVo));
    }

    /**
     * 完工打印一键入库
     */
    //@SaCheckPermission("warehouse:incomingPrint:cgPrint:warehousing")
    @PostMapping("/oneKeyWarehousingWip")
    public R<Void> oneKeyWarehousingWip(@RequestBody OneKeyWarehousingVo oneKeyWarehousingVo) {
        return toAjax(incomingMaterialPrintingService.oneKeyWarehousingWip(oneKeyWarehousingVo));
    }

    /**
     * 根据唯一标识修改状态(feign调用)
     */
//    @PostMapping("/getDataByOnlyMark")
//    public AjaxResult getDataByOnlyMark(@RequestBody ReturnStatusVo returnStatusVo) {
//        return AjaxResult.success(incomingMaterialPrintingService.getDataByOnlyMark(returnStatusVo));
//    }

    /**
     * 根据唯一标识获取采购入库单号(feign调用)
     */
//    @GetMapping("/getReceiptNo")
//    public String getReceiptNo(String onlyMark) {
//        return incomingMaterialPrintingService.getReceiptNo(onlyMark);
//    }

    /**
     * 根据批次号修改来料打印状态(feign调用)
     */
    @PostMapping("/updatePrintStatus")
    public void updatePrintStatus(@RequestBody UpdatePrintStatusVo updatePrintStatusVo) {
        incomingMaterialPrintingService.updatePrintStatus(updatePrintStatusVo);
    }
}
